package com.xuecheng.teaching.job;

import cn.hutool.core.date.DateUtil;
import com.xuecheng.commons.model.dto.CommentStatusDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.teaching.service.CourseCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//定时更新评论任务类
@Component
@Slf4j
public class CommentJob {

    @Autowired
    private CourseCommentService courseCommentService;

    private PageRequest pageRequest;

    private CommentStatusDto dto;

    private ResponseResult responseResult;

    public PageRequest getPageRequest() {
        return pageRequest;
    }

    public void setPageRequest(PageRequest pageRequest) {
        this.pageRequest = pageRequest;
    }

    public CommentStatusDto getDto() {
        return dto;
    }

    public void setDto(CommentStatusDto dto) {
        this.dto = dto;
    }

    public ResponseResult getResponseResult() {
        return responseResult;
    }

    public void setResponseResult(ResponseResult responseResult) {
        this.responseResult = responseResult;
    }

    //@Scheduled(cron = "* 0/30 * * * ? ")    //从0分钟开始 每隔30分钟更新一次
    //public void updateComment(){
    //    log.info("定时更新评论: {}", DateUtil.now());
    //    ResponseResult responseResult = courseCommentService.pageCourseComment(this.pageRequest, this.dto);
    //    //赋值
    //    this.setResponseResult(responseResult);
    //}
}
